

import java.io.IOException;
import java.util.*;
import org.boehn.kmlframework.kml.Document;
import org.boehn.kmlframework.kml.Kml;
import org.boehn.kmlframework.kml.KmlException;
import org.boehn.kmlframework.kml.Placemark;

public class KMLgen implements Runnable {
HashSet<Entity> group = new HashSet<Entity>();
public KMLgen(Temp b){
	group = b.getgroup1();
}


private boolean end = true;
	

	
	
public void run(){
while(end == true){
	try{
	write();
	} catch(IOException iex){
	end = true;
} catch(KmlException kex){
	end = true;
	try{
		Thread.sleep(1000);
	}catch(InterruptedException ex){
		ex.printStackTrace();
	}
	
}
}
}
public void write() throws IOException, KmlException {
		
		// We add a document to the kml
		
		Kml kml = new Kml();
		Document document = new Document();
		kml.setFeature(document);
		
		// We add the placemarks to the Document
		
		for (Entity one: group){
			one.go();
			document.addFeature(one.mark);
		}
		
		
		// We generate the kml file
		kml.createKml("Ifi.kml");
		
		
	}

}
